<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>选择禁用时长</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/web/res/css/xadmin.css">
    <script src="/web/res/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/web/res/js/xadmin.js"></script>
</head>

<body style="background-color: white;">
    <div class="layui-fluid" id="orderEdit">
        <form class="layui-form layui-form-pane" id="formsubmit" style="width: 500px;margin:20px auto" action="/after/user/upstate">
            <input type="hidden" name="id" id="id" value="${(userId?c)!''}"/>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">禁用时长/小时</label>
                    <div class="layui-input-block">
                        <select class="hourSelect" lay-verify="required" lay-search lay-filter="hourSelect" name="hour">
                        </select>
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button type="button" class="layui-btn layui-btn-radius" lay-submit lay-filter="save" >&emsp;保存&emsp;</button>
                    <button type="button" class="layui-btn layui-btn-primary layui-btn-radius" onclick="xadmin.close()">&emsp;返回&emsp;</button>
                </div>
            </div>
        </form>
    </div>
    <script>
        layui.use('form', function () {
            let $ = layui.$;
            var form = layui.form;
            form.render();

            getHour()
            function getHour() {


                // let map = new Map();
                // map.set(3, "3小时");
                // map.set(6, "6小时");
                // map.set(12, "12小时");
                // map.set(24, "1天");
                // map.set(72, "3天");

                // for (let key of map.keys()){
                //
                //     console.log(key)
                // }

                addEle($(".hourSelect"), '3小时', 3);
                addEle($(".hourSelect"), '6小时', 6);
                addEle($(".hourSelect"), '12小时', 12);
                addEle($(".hourSelect"), '1天', 24);
                addEle($(".hourSelect"), '3天', 72);
                addEle($(".hourSelect"), '永久', -1);


                // for(let i=1;i<=240;i++) {
                //     addEle($(".hourSelect"), i, i);
                // }
                // addEle($(".hourSelect"), '永久', -1);
            }





            //向select中 追加内容
            function addEle(ele, value, id) {
                var optionStr = "";
                optionStr = "<option value=" + id + " >" + value + "</option>";
                ele.append(optionStr);
            }
            //重新渲染select
            form.render('select');

            form.on('submit('+$("button[lay-submit]:eq(0)").attr("lay-filter")+')', function(data){
                layer.confirm('确认要禁用该账户吗？', function (index) {
                    ajaxPost($,$("#formsubmit").attr("action"),{"id":$("#id").val(),"state":2,"hour":$('#hour').val()},function (data) {
                        if (data.code == 0) {
                            layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                                xadmin.father_reload();
                            });
                        } else {
                            layer.msg(data.msg, {icon: 2, time: 3000}, function(){
                                xadmin.close();
                            });
                        }
                    });
                });
            });
        });
    </script>
</body>

</html>
